/*******************************************************************************
 **  Name: sparc2usb.cpp                                                      **
 **  Description:                                                             **
 **                                                                           **
 **  CDDL: Open Source Initiative (OSI) Approved License                      **
 **                                                                           **
 **  Copyright (c) 2009-2010 Barry "Gian" James  <bjames@munixos.net>         **
 **  All rights reserved.                                                     **
 **                                                                           **
 **  The contents of this file are subject to the terms of the CDDL:          **
 **  Common Development and Distribution License (the "License").             **
 **  You may not use this file except in compliance with the License.         **
 **                                                                           **
 **  You can obtain a copy of the license at $PROJECT_ROOT/LICENSE            **
 **  or http://www.opensolaris.org/os/licensing.  This code is Open Source    **
 **  and you are free to use it within the confines of the license, even      **
 **  for your own closed-source commercial projects, as long as you follow    **
 **  the terms set forth in the CDDL.                                         **
 **                                                                           **
 **  When distributing Covered Code, include this CDDL HEADER in each         **
 **  file and include the License file at $PROJECT_ROOT/LICENSE.              **
 **  If applicable, add the following below this CDDL HEADER, with the        **
 **  fields enclosed by brackets "[]" replaced with your own identifying      **
 **  information: Portions Copyright [yyyy] [name of copyright owner]         **
 **                                                                           **
 ******************************************************************************/
#define sparc2usb_cpp_ID_ "$Id: //depot/atbios/trunk/atbios.h#3 $"
#include "kbd.h"

// This value just gets added to the MAKE code to generate the BREAK code
#define SPARC_BREAK_CODE 	0x80

// Table mapping sparc make to USB usage data
// The location in the array maps to the Sparc keyboard key #
// { sparc make, usb usage id }
const char SparcToUSB[][2] =
{
	{ 0x00, 0x00 },	
	{ 0x05, 0x3A },	// F1
	{ 0x06, 0x3B },	// F2
	{ 0x08, 0x3C },	// F3
	{ 0x0A, 0x3D },	// F4
	{ 0x0C, 0x3E },	// F5
	{ 0x0E, 0x3F },	// F6
	{ 0x10, 0x40 },	// F7
	{ 0x11, 0x41 },	// F8
	{ 0x12, 0x42 },	// F9
	{ 0x07, 0x43 },	// F10
	{ 0x09, 0x44 },	// F11
	{ 0x0b, 0x45 },	// F12
	{ 0x58, 0x31 },	// \ and |
	{ 0x42, 0x4C },	// delete
	{ 0x01, 0x78 },	// stop
	{ 0x03, 0x79 },	// again
	{ 0x15, 0x48 },	// pause
	{ 0x16, 0x46 },	// pr sc
	{ 0x17, 0x84 },	// break
	{ 0x62, 0x83 },
	{ 0x19, 0xA3 },	// props
	{ 0x1A, 0x7A },
	{ 0x1D, 0x29 },
	{ 0x1E, 0x1E },	// 1
	{ 0x1F, 0x1F },	// 2
	{ 0x20, 0x20 },	// 3
	{ 0x21, 0x21 },	// 4
	{ 0x22, 0x22 },	// 5
	{ 0x23, 0x23 },	// 6
	{ 0x24, 0x24 },	// 7
	{ 0x25, 0x25 },	// 8
	{ 0x26, 0x26 },	// 9
	{ 0x27, 0x27 },	// 0
	{ 0x28, 0x2D },	// -
	{ 0x29, 0x2E },	// = +
	{ 0x2B, 0x2A },	// Backspace
	{ 0x2D, 0x67 },	// kpd =
	{ 0x2E, 0x54 },	// kpd /
	{ 0x2F, 0x55 },	// kpd *
	{ 0x47, 0x56 },	// kpd -
	{ 0x31, 0x00 },	// front
	{ 0x33, 0x7C },	// copy
	{ 0x35, 0x2B },	// tab
	{ 0x36, 0x14 },	// Q
	{ 0x37, 0x1A },	// W
	{ 0x38, 0x08 },	// E
	{ 0x39, 0x15 },	// R
	{ 0x3A, 0x17 },	// T
	{ 0x3B, 0x1C },	// Y
	{ 0x3C, 0x18 },	// U
	{ 0x3D, 0x0C },	// I
	{ 0x3E, 0x12 },	// O
	{ 0x3F, 0x13 },	// P
	{ 0x40, 0x2F },	// [
	{ 0x41, 0x30 },	// ]
	{ 0x59, 0x28 },	// RETURN 
	{ 0x44, 0x5F },
	{ 0x45, 0x60 },
	{ 0x46, 0x61 },
	{ 0x7D, 0x57 },
	{ 0x48, 0x00 },	// open
	{ 0x49, 0x7D },
	{ 0x4C, 0x0E },
	{ 0x4D, 0x04 },	// A
	{ 0x4E, 0x16 },	// S
	{ 0x4F, 0x07 },	// D
	{ 0x50, 0x09 },	// F
	{ 0x51, 0x0A },	// G
	{ 0x52, 0x0B },	// H
	{ 0x53, 0x0D },	// J
	{ 0x54, 0x0E },	// K
	{ 0x55, 0x0F },	// L
	{ 0x56, 0x33 },	// ;
	{ 0x57, 0x34 },	// '
	{ 0x2A, 0x35 },	// ~
	{ 0x5B, 0x5C },	// left cursor
	{ 0x5C, 0x5D },	// kpd 5
	{ 0x5D, 0x5E },	// right cursor
	{ 0x5F, 0x7E },	// find
	{ 0x61, 0x7B },	// cut
	{ 0x63, 0x44 },	// shift
	{ 0x64, 0x1D },	// Z
	{ 0x65, 0x1B },	// X
	{ 0x66, 0x06 },	// C
	{ 0x67, 0x19 },	// V
	{ 0x68, 0x05 },	// B
	{ 0x69, 0x11 },	// N
	{ 0x6A, 0x10 },	// M
	{ 0x6B, 0x36 }, // ,
	{ 0x6C, 0x37 },
	{ 0x6D, 0x38 },
	{ 0x6E, 0xE5 },
	{ 0x6F, 0x00 },	// line feed
	{ 0x70, 0x59 },	// end
	{ 0x71, 0x5A },	// down cursor
	{ 0x72, 0x5B },	// pgdn
	{ 0x5A, 0x58 },	// enter
	{ 0x76, 0x75 },	// help
	{ 0x77, 0x82 },	// caps
	{ 0x13, 0xE2 },	// alt
	{ 0x78, 0xE3 },	// Left triangle mappped to left gui
	{ 0x79, 0x2C },	// space bar
	{ 0x7A, 0xE7 },	// right trangle
	{ 0x43, 0x65 },	// compose (windows app)
	{ 0x0D, 0x00 },	// graph
	{ 0x5E, 0x49 },	// insert
	{ 0x32, 0x63 }	// delete
};

// This is also the same pattern used for RESET_ACK
const char SelfTestPass[] =
{
	0x0FF,
	0x004,
	0x07F
};

const char SelfTestFail[] =
{
	0x07E,
	0x001
};

// There is a 3rd hex value that is sent and it is the hex of the key that's pressed down
const char SelfTestKeypress[] =
{
	0x0FF,
	0x004,
};

